﻿using System.Threading.Tasks;
using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.StandardApprovalFlow.Dto;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.StandardApprovalFlow
{
    /// <summary>
    /// 通用审批流程接口
    /// </summary>
    [Authorize]
    [ApiController]
    [Route("api/StandardApproval")]
    public class StandardApprovalController : BPMReportPlatformController
    {
        private readonly IStandardApprovalAppService _standardApprovalAppService;

        public StandardApprovalController(IStandardApprovalAppService standardApprovalAppService)
        {
            _standardApprovalAppService = standardApprovalAppService;
        }

        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("GetAllAsync")]
        public async Task<PagedResultDto<GetStandardApprovalOutput>> GetAllAsync([FromBody] GetStandardApprovalInput input)
        {
            return await _standardApprovalAppService.GetAllAsync(input);
        }

        /// <summary>
        /// 导出数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("ExportAsync")]
        public async Task<XlsxFileResult<GetStandardApprovalOutput>> ExportAsync([FromBody] GetStandardApprovalInput input)
        {
            var rst = await _standardApprovalAppService.ExportAsync(input);
            return new XlsxFileResult<GetStandardApprovalOutput>(rst, "导出Excel");
        }

        /// <summary>
        /// 导出有运单的通用审批数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("ExportTransportAsync")]
        public async Task<XlsxFileResult<ExportStandardApprovalOutput>> ExportTransportAsync([FromBody] GetStandardApprovalInput input)
        {
            var rst = await _standardApprovalAppService.ExportTransportAsync(input);
            return new XlsxFileResult<ExportStandardApprovalOutput>(rst, "导出Excel");
        }
        /// <summary>
        /// 导出加急运输数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("ExportJJBCAsync")]
        public async Task<XlsxFileResult<ExportStandardApprovalJJBCOutput>> ExportJJBCAsync([FromBody] GetStandardApprovalInput input)
        {
            var rst = await _standardApprovalAppService.ExportJJBCAsync(input);
            return new XlsxFileResult<ExportStandardApprovalJJBCOutput>(rst, "导出Excel");
        }
        /// <summary>
        /// 导出不足吨位发货数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("ExportBZDWAsync")]
        public async Task<XlsxFileResult<ExportStandardApprovalBZDWOutput>> ExportBZDWAsync([FromBody] GetStandardApprovalInput input)
        {
            var rst = await _standardApprovalAppService.ExportBZDWAsync(input);
            return new XlsxFileResult<ExportStandardApprovalBZDWOutput>(rst, "导出Excel");
        }
        /// <summary>
        /// 导出90单发货数据
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("Export90Async")]
        public async Task<XlsxFileResult<ExportStandardApproval90Output>> Export90Async([FromBody] GetStandardApprovalInput input)
        {
            var rst = await _standardApprovalAppService.Export90Async(input);
            return new XlsxFileResult<ExportStandardApproval90Output>(rst, "导出Excel");
        }
    }
}
